<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>全选全不选</title>
    <script>

        function checkAll(obj){

            let flag=obj.checked;

            let itmeObjArr=document.getElementsByName("item");
            for (let i = 0; i < itmeObjArr.length; i++) {
                itmeObjArr[i].checked=flag;
            }
        }
        function reverseSelect() {
            let itmeObjArr =document.getElementsByName("item");
            for (let i = 0; i <itmeObjArr.length ; i++) {
                itmeObjArr[i].checked=!itmeObjArr[i].checked;

            }
        }

    </script>
</head>
<body>
<h4>请选择宁要买的奥特曼</h4>
<input type="checkbox" name="item" value="15000" /> 迪迦奥特曼<br />
<input type="checkbox" name="item" value="2000"  /> 盖亚奥特曼<br />
<input type="checkbox" name="item" value="2000"  /> 戴拿奥特曼<br />
<input type="checkbox" name="item" value="8000"  /> 奈克萨斯奥特曼<br />
<input type="checkbox" name="item" value="2000"  /> 梦比优斯奥特曼<br />
<hr/>
<input type="checkbox" id="all" onclick="checkAll(this)" />全选/全不选 &nbsp;

<input type="button" id="reverse" onclick="reverseSelect()"  value=" 反 选 "/>&nbsp;
</body>
</html>